
import codecs

class lines:
    # read big text file as iterator
    def __init__(self , flpath, encoding):
        self.flpath = flpath
        self.sfile_fl = codecs.open(flpath, 'r', encoding) 
    def __getitem__( self , index ):
        line = self.sfile_fl.readline()
        if line:
            return line
        else:
            raise IndexError

class lines2:
    ''' rewrite of "lines" class
    '''
    def __init__(self,fpath):
        self.fpath = fpath
        self.fhandle = open(self.fpath, 'r')

    def __getitem__(self):
        line = self.fhandle.readline()
        if line:
            return line
        else:
            raise IndexError

    def getLine(self):
        return self.__getitem__()


def lineno(inpFile, lineNo):
    if lineNo < 1 : return ''
    inpLineNo = 0
    inpFileObj = open(inpFile, 'r')
    while 1:
        if inpLineNo <> lineNo:
            inpLineNo += 1
            inpLine = inpFileObj.readline()
        else:
            inpFileObj.close()
            return inpLine

